package sk.talker.atlantis.icefaces.beans;

mport java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import javax.faces.component.html.HtmlInputTextarea;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import com.icesoft.faces.webapp.xmlhttp.*;
import com.icesoft.faces.async.render.*;
import com.icesoft.faces.component.ext.HtmlOutputText;
import com.icesoft.faces.component.ext.HtmlPanelGrid;

public class TalkerInputBean implements Renderable {
	
	private PersistentFacesState state;
	private OnDemandRenderer chatWriter;

	private com.icesoft.faces.component.ext.HtmlPanelGrid chatarea;

	public TalkerInputBean() {      
        init();
    }
	
	private void init() {
		state = PersistentFacesState.getInstance();
		chatarea = new HtmlPanelGrid();
	}

    public com.icesoft.faces.component.ext.HtmlPanelGrid getChatarea() {
    	myText1 = new com.icesoft.faces.component.ext.HtmlOutputText();
		myText1.setEscape(false);
		myText1.setValue("<span style=\"color:red\">b&nbsp;&nbsp;&nbsp;um bac</span>");
		List deticky1 = chatarea1.getChildren(); 
		deticky1.add(myText1);
		return chatarea1;
	}

	public void setChatarea(com.icesoft.faces.component.ext.HtmlPanelGrid chatarea1) {
		this.chatarea = chatarea1;
	}

	public void setRenderManager(RenderManager renderManager) {
		chatWriter = renderManager.getOnDemandRenderer("chatWriter");
		chatWriter.add(this);
		chatWriter.requestRender();
	}
	
	public RenderManager getRenderManager() {
        return null;
    }
	
	public PersistentFacesState getState() {
		return state;
	}

	public void renderingException(RenderingException renderingException) {
		performCleanup();
	}
	
	protected boolean performCleanup(){
        try{
            if(chatWriter != null){
                chatWriter.requestStop();
                chatWriter.remove(this);
                chatWriter.dispose();
                chatWriter = null;
            }
            return true;
        } catch (Exception failedCleanup){
        	//TODO: ...
        }
        return false;
    }
}
